#!/usr/bin/env python
#! -*- coding: utf-8 -*-
import time

from mongoengine import Document, StringField, IntField, DateTimeField, ReferenceField, FloatField, BooleanField

class SFLZ_StdMedicine(Document):
    """
    标准药品库信息
    """
    sn = IntField()
    ypid = StringField()
    name = StringField()
    manufacture = StringField()
    enterprise_no = StringField()
    approval_no = StringField()
    category = StringField()
    category_code = StringField()
    phar_efficacy = StringField()
    phar_efficacy_code = StringField()
    varity_name_cn = StringField()
    varity_name_en = StringField()
    varity_name_code = StringField()
    acid_base = StringField()
    acid_base_code = StringField()
    dosage_form = StringField()
    dosage_form_code = StringField()
    specification = StringField()
    formulation_spec_code = StringField()
    factor_coeff = FloatField()
    factor_coeff_code = StringField()
    material_packaging = StringField()
    min_packaging_unit = StringField()
    min_preparation_unit = StringField()
    difference_note = StringField()
    remark_code = StringField()
    imported_patented_drug = IntField(default=0) 
    original_drug = IntField(default=0) 
    low_priced_drug = IntField(default=0) 
    fixed_prod_drug = IntField(default=0) 
    original_prod_company_name = StringField()
    original_ennterprise_code = StringField()
    original_approval_no = StringField()
    approval_start_date = DateTimeField()
    approval_cancelled_date = DateTimeField()
    ypid3 = StringField()
    ypid_change = IntField()
    modify_record = StringField()
    theory_base09_drug = IntField()
    base_09drug = IntField()
    theory_base12_drug = IntField()
    base_12drug = IntField()
    base_12drug_category = StringField()
    medical_insurance09_flag = IntField()
    medical_insurance17_version = StringField()
    numbering = StringField()
    drug_classification = StringField()
    drug_classification_code = StringField()
    classification_primary = StringField()
    classification_secondary = StringField()
    classification_thirdary = StringField()
    classification_fourth = StringField()
    remark = StringField()

    obsoleted = BooleanField(default=False)
    created_at = FloatField(default=time.time() * 1000)
    updated_at = FloatField(default=time.time() * 1000)
    sort_value = IntField(default=1)

    meta = {
        'collection': 'SFLZ_StdMedicine',    #指定collection的名字
        'ordering': ['-updated_at'],
        'indexes': [
            ('sn'),
            ('ypid'),
            ('enterprise_no')
        ]
    }
